package com.itheima.reggie.controller;

import com.itheima.reggie.common.ResultInfo;
import com.itheima.reggie.domain.Dish;
import com.itheima.reggie.domain.Setmeal;
import com.itheima.reggie.service.SetmealService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 套餐分类
 *
 * @Author Yang
 * @Date 2023/3/8 17:29
 */
@RestController
public class SetmealController {

    @Autowired
    private SetmealService setmealService;

    //查询所有套餐

    @GetMapping("/setmeal/list")
    @Cacheable(value = "setmeal",key = "#categoryId")
    public ResultInfo list(Long categoryId, Integer status) {
        List<Setmeal> list = setmealService.list(categoryId, status);
        return ResultInfo.success(list);
    }

    @GetMapping("/setmeal/dish/{id}")
    public ResultInfo dish(@PathVariable Long id){
        List <Dish> list = setmealService.dish(id);
        return ResultInfo.success(list);
    }

}
